<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <base href="<?php echo base_url() ?>"/>
        <title>乐天！ &raquo; 首页</title>
        <meta name="generator" content="Order 1.0"/>
        <link rel="stylesheet" href="css/style.css" type="text/css"/>
        <link rel="stylesheet" href="jquery-ui/css/ui-lightness/jquery-ui-1.9.0.custom.min.css"/>
        <script src="jquery-ui/js/jquery-1.8.2.js" type="text/javascript" charset="utf-8"></script>
        <script src="jquery-ui/js/jquery-ui-1.9.0.custom.min.js" type="text/javascript" charset="utf-8"></script>
        <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css"/>
        <script src="js/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
        <script src="js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
        <script>
            $(function () {
                $(".link_mod").click(function () {
                    var url = $(this).attr("href");
                    $.post(url, function (result) {
                        $("#order_add").html(result);
                        $("#order_add").show();
                        $("#bgDiv").show();
                    });
                    return false;
                })

                $('#filter').change(function(){
                    alert('11');
                });
                $(".quanxuan").click(function () {
                    var tables = document.getElementsByTagName("table");
                    var checkboxs = tables[0].getElementsByTagName("input");
                    if (this.checked) {
                        for (var i = 0; i < checkboxs.length; i++) {
                            if (checkboxs[i].hidden == false) {
                                checkboxs[i].checked = true;
                            }
                        }
                    }
                    else {
                        for (var i = 0; i < checkboxs.length; i++) {
                            if (checkboxs[i].hidden == false) {
                                checkboxs[i].checked = false;
                            }
                        }
                    }
                })

                $(".confirm").click(function () {
                    var tables = document.getElementsByTagName("table");
                    var checkboxs = tables[0].getElementsByTagName("input");
                    var data = new Array();
                    for (var i = 0; i < checkboxs.length; i++) {
                        if (checkboxs[i].checked) {
                            data.push(checkboxs[i].value);
                        }
                    }
                    if (data.length != 0) {
                        var url = this.name;
                        var turnForm = document.createElement("form");
                        //一定要加入到body中！！
                        document.body.appendChild(turnForm);
                        turnForm.method = 'post';
                        turnForm.action = url;
                        // turnForm.target = '_blank';
                        //创建隐藏表单
                        for (var i = 0; i < data.length; i++) {
                            var newElement = document.createElement("input");
                            newElement.setAttribute("name", i);
                            newElement.setAttribute("type", "hidden");
                            newElement.setAttribute("value", data[i]);
                            turnForm.appendChild(newElement);
                        }
                        turnForm.submit();
                    }
                    else {
                        $('#showup').html('请选择对象！');
                        $('#showup').fadeIn(1000);
                        $('#showup').fadeOut(3000);
                    }
                })
            });
        </script>
        <style>
            .confirm {
                height: 32px;
                font-weight: bold;
                font-size: 12px;
                width: 80px;
                background: #7FA448;
                margin: 0;
                border: none;
                cursor: pointer;
                color: white;
                display: inline;
            }

            .confirm:hover {
                background: #8cb352;
            }
        </style>
    </head>
    <body>
        <div id="bgDiv"></div>
        <div id="order_add"  style="z-index: 9999;border: 5px solid #CCC;background:white;padding:20px;position:fixed;top:50%;left:50%;margin-left: -200px;margin-top: -120px;width:400px;height: 240px;display: none">
        </div>
        <div id="container">
            <div id="header">
                <div id="header-inner">
                    <h1><span><a href="#">乐天！</a></span></h1>

                    <h2>订单管理系统</h2>

                    <div class="clear"></div>
                    <ul class="sw_menu">
                        <li><a href=<?php echo site_url('login')?>  >首页</a></li>
                        <li><a href=# class="sw_menu_current">管理</a></li>
                        <li><a href=#>筛选</a></li>
                        <?php
                            if($is_admin)  
                                echo '<li><a href='.site_url('admin').'>后台</a></li>';
                        ?>         
                    </ul>
                </div>
            </div>
            <div id="sidebar">
                <div id="sidebar-inner">
                    <ul>
                                               <li>
                            <?php
                            if($ret['p1']){
                                echo  '<a  href='.site_url("order/new_order") .'>新建订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">新建订单</a>';
                            }
                            ?>
                           
                        </li>
                        <li>
                            <?php
                            if($ret['p2']){
                                echo  '<a  href='.site_url("order/wait_for_pay") .'>待付款订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">待付款订单</a>';
                            }
                            ?>
                        </li>
                        <li class="select">>
                            <?php
                            if($ret['p3']){
                                echo  '<a  href='.site_url("order/wait_for_buy") .'>待购货订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">待购货订单</a>';
                            }
                            ?>
                        </li>
                        <li>
                            <?php
                            if($ret['p4']){
                                echo  '<a  href='.site_url("order/wait_for_delivery") .'>待发货订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">待发货订单</a>';
                            }
                            ?>
                        </li>
                        <li>
                        <?php
                            if($ret['p5']){
                                echo  '<a  href='.site_url("order/order_allocation") .'>已发货订单</a>';
                            }
                            else{
                               echo  '<a style="color:gray"  href="javascript:void(0)">已发货订单</a>';
                            }
                            ?>                    
                        </li>
                        <div class="clear"></div>
                    </ul>
                </div>
            </div>
            <div class="clear"></div>
            <div id="content-wrapper" style="width:1050px">
                <div style=" position:absolute;top:20px;left:250px;display: none;line-height:40px;height: 40px;color:white; width:200px;font-size:16px;background:#cc6600;text-align: center;z-index:99;"
                     id='showup'>正在提交订单
                </div>
                <div id="content">
                    <div style="float:left;">
                        <h3 id="comments-title">  
                            订单筛选：
                            <select name="paymentMethod" id="filter" style="width:130px; font-family: inherit" >
                                <option>所有订单</option>  
                                <option>未采购</option>  
                                <option>已采购</option> 
                            </select></h3>
                    </div>
                    <div style="float:right;">
                        全选
                        <input type="checkbox" name="quanxuan" class="quanxuan"/>
                        <?php
                        $data = array(
                            'name' => site_url("order/wait_for_buy_update_confirm/" . $num),
                            'value' => '确认已配货',
                            'type' => 'button',
                            'class' => 'confirm',
                        );
                        echo form_input($data);
                        ?>
                    </div>
                    <div class="clear"></div>
                </div>
                <div class="comment-form">
                    <table>
                        <tr>
                            <th style="width:40px;">勾选</th> 
                            <th style="width:80px;">订单状态</th>
                            <th style="width:86px;">日期</th>
                            <th style="width:75px;">订单号</th>
                            <th style="width:75px;">商品编号</th>
                            <th style="width:134px">图片</th>
                            <th style="width:100px">销售链接</th>
                            <th style="width:80px">颜色/尺寸</th>
                            <th style="width:35px;">数量
                            <th>修改采购</th>
                        </tr>
                        <?php
                        $pre = -1;
                        $data = array();
                        if (!empty($list)) {
                            foreach ($list as $k => $v) {
                                if ($pre == $v['id']) {
                                    $data[] = $v;
                                } else {
                                    if (count($data) != 0) {
                                        echo "<tr>";
                                        if ($data[0]['state'] == '1') {
                                            echo "<td rowspan='" . count($data) . "'>";
                                            $input_data = array(
                                                "value" => $data[0]['id'],
                                                "hidden" => 'true',
                                            );
                                            echo form_checkbox($input_data);
                                            echo "</td>";
                                            echo "<td rowspan='" . count($data) . "'>";
                                            echo "未采购";
                                            echo "</td>";
                                        } else {
                                            echo "<td rowspan='" . count($data) . "'>";
                                            $input_data = array(
                                                "value" => $data[0]['id'],
                                            );
                                            echo form_checkbox($input_data);
                                            echo "</td>";
                                            echo "<td rowspan='" . count($data) . "'>";
                                            echo "已采购";
                                            echo "</td>";
                                        }
                                        echo "<td>" . $data[0]['orderTime'] . "</td>";
                                        echo "<td>" . $data[0]['orderNumber'] . "</td>";
                                        echo "<td>" . $data[0]['commodityNumber'] . "</td>";
                                        echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\"><img src='" . $data[0]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                                        echo "<td><a href='" . $data[0]['link'] . "' target='_blank' >" . $data[0]['link'] . "</a></td>";
                                        echo "<td>" . $data[0]['colorAndSize'] . "</td>";
                                        echo "<td>" . $data[0]['amount'] . "</td>";
                                        echo "<td><a href='" . site_url("order/wait_for_buy_commodity/" . $data[0]['commodityId'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                                        echo "</tr>";

                                        for ($i = 1; $i < count($data); $i++) {
                                            echo "<tr>";
                                            echo "<td>" . $data[$i]['orderTime'] . "</td>";
                                            echo "<td>" . $data[$i]['orderNumber'] . "</td>";
                                            echo "<td>" . $data[$i]['commodityNumber'] . "</td>";
                                            echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\"><img src='" . $data[$i]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                                            echo "<td><a href='" . $data[$i]['link'] . "' target='_blank' >" . $data[$i]['link'] . "</a></td>";
                                            echo "<td>" . $data[$i]['colorAndSize'] . "</td>";
                                            echo "<td>" . $data[$i]['amount'] . "</td>";
                                            echo "<td><a href='" . site_url("order/wait_for_buy_commodity/" . $data[$i]['commodityId'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                                            echo "</tr>";
                                        }
                                    }
                                    $pre = $v['id'];
                                    $data = array();
                                    $data[] = $v;
                                }
                            }
                            if (count($data) != 0) {
                                echo "<tr>";
                                if ($data[0]['state'] == '1') {
                                    echo "<td rowspan='" . count($data) . "'>";
                                    $input_data = array(
                                        "value" => $data[0]['id'],
                                        "hidden" => 'true',
                                    );
                                    echo form_checkbox($input_data);
                                    echo "</td>";
                                    echo "<td rowspan='" . count($data) . "'>";
                                    echo "未采购";
                                    echo "</td>";
                                } else {
                                    echo "<td rowspan='" . count($data) . "'>";
                                    $input_data = array(
                                        "value" => $data[0]['id'],
                                    );
                                    echo form_checkbox($input_data);
                                    echo "</td>";
                                    echo "<td rowspan='" . count($data) . "'>";
                                    echo "已采购";
                                    echo "</td>";
                                }
                                echo "<td>" . $data[0]['orderTime'] . "</td>";
                                echo "<td>" . $data[0]['orderNumber'] . "</td>";
                                echo "<td>" . $data[0]['commodityNumber'] . "</td>";
                                echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\">
<img src='" . $data[0]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                                echo "<td><a href='" . $data[0]['link'] . "' target='_blank' >" . $data[0]['link'] . "</a></td>";
                                echo "<td>" . $data[0]['colorAndSize'] . "</td>";
                                echo "<td>" . $data[0]['amount'] . "</td>";
                                echo "<td><a href='" . site_url("order/wait_for_buy_commodity/" . $data[0]['commodityId'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                                echo "</tr>";

                                for ($i = 1; $i < count($data); $i++) {
                                    echo "<tr>";
                                    echo "<td>" . $data[$i]['orderTime'] . "</td>";
                                    echo "<td>" . $data[$i]['orderNumber'] . "</td>";
                                    echo "<td>" . $data[$i]['commodityNumber'] . "</td>";
                                    echo "<td><div style=\"border:1px solid #ffecf1;padding:3px;background-color:#efefef\">
<img src='" . $data[$i]['imagePath'] . "'width='126px' height='150px' /></div></td>";
                                    echo "<td><a href='" . $data[$i]['link'] . "' target='_blank' >" . $data[$i]['link'] . "</a></td>";
                                    echo "<td>" . $data[$i]['colorAndSize'] . "</td>";
                                    echo "<td>" . $data[$i]['amount'] . "</td>";
                                    echo "<td><a href='" . site_url("order/wait_for_buy_commodity/" . $data[$i]['commodityId'] . "/" . $num) . "' class='link_mod'>&nbsp;</a></td>";
                                    echo "</tr>";
                                }
                            }
                        }
                        ?>
                    </table>
                    <div class="clear"></div>
                    <?php echo $this->pagination->create_links(); ?>
                    <div class="clear"></div>
                </div>
            </div>
            <div class="clear"></div>
            <div id="footer">
                <hr/>
                <ul>
                    <li>
                        Powered by <a href=#>Swan 1.3.0</a>
                    </li>
                </ul>
            </div>
        </div>
        </div>
    </body>
</html>

